package com.bw.z.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bw.z.R;

public class GlideUtils {
    private static GlideUtils manager;
    private static Context context;

    public GlideUtils(Context context) {
        this.context = context;
    }

    public static GlideUtils getInstance() {
        if (manager == null)
            manager = new GlideUtils(context);
        return manager;
    }

    public void GlideImageUrl(int path, ImageView imageView) {
        Glide.with(imageView.getContext()).load(path).transform(new CenterCrop()).into(imageView);
    }

    public void GlideImage(String path, ImageView imageView) {
        Glide.with(imageView.getContext()).load(path).transform(new CenterCrop()).into(imageView);
    }

    public void GlideCircleCropImage(String path, ImageView imageView) {
        Glide.with(imageView.getContext()).load(path).transform(new CenterCrop(), new CircleCrop()).into(imageView);
    }

    public void GlideFilletImage(String path, ImageView imageView, int index) {
        Glide.with(imageView.getContext()).load(path).transform(new CenterCrop(), new RoundedCorners(index)).into(imageView);
    }
}
